package com.it.tydic.estate.module.controller.xqgl;

import com.it.tydic.estate.common.annotation.ControllerDesc;
import com.it.tydic.estate.common.aop.Result;
import com.it.tydic.estate.common.constants.LogConstants;
import com.it.tydic.estate.module.model.inner.Fangjianguanli;
import com.it.tydic.estate.module.model.inner.Louyu;
import com.it.tydic.estate.module.service.FJglService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("fjgl")
@Api(tags = "房间管理")
public class FJglController {
    @Autowired
    private FJglService fJglService;

    /**
     * 新增或修改
     *
     * @param fangjianguanli 房间对象
     * @return
     */
    @PostMapping("/addOrUpload")
    @ApiOperation(value = "房间添加或修改")
    @ControllerDesc(description = LogConstants.addOrUpdate_data)
    public Result addOrUpload(@RequestBody Fangjianguanli fangjianguanli) {

        return fJglService.addOrUpload(fangjianguanli);
    }

    /**
     * 条件分页查房间信息
     *
     * @param fjglMap 查询条件
     * @return
     */
    @PostMapping("query")
    @ApiOperation(value = "条件查房间信息", notes = "条件查房间信息")
    public Result queryList(@RequestBody Map<String, Object> fjglMap) {
        return fJglService.queryList(fjglMap);
    }

    /**
     * 根据主键删除房间
     *
     * @param id 主键
     * @return
     */
    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "根据主键删除房间", notes = "根据主键删除房间")
    @ControllerDesc(description = LogConstants.delete_data)
    public Result deleteById(@PathVariable String id) {

        return fJglService.deleteById(id);
    }

    /**
     * 批量删除
     *
     * @param list 主键集合
     * @return
     */
    @PostMapping("/deleteBatch")
    @ApiOperation(value = "批量删除", notes = "批量删除")
    @ControllerDesc(description = LogConstants.delete_data)
    public Result deleteBatch(@RequestBody List<String> list) {
        return fJglService.deleteBatch(list);
    }
    /**
     * 根据主键查询房间
     *
     * @return
     */
    @GetMapping("queryById/{id}")
    @ApiOperation(value = "根据主键查询房间", notes = "根据主键查询房间")
    public Result queryById(@PathVariable String id) {
        return fJglService.queryById(id);
    }

    /**
     * 根据楼宇主键查楼宇房间
     * @param id
     * @return
     */
    @GetMapping("queryByLyId/{id}")
    @ApiOperation(value = "根据楼宇主键查楼宇房间", notes = "根据楼宇主键查楼宇房间")
    public Result queryByLyId(@PathVariable String id) {
        return fJglService.queryByLyId(id);
    }

    /**
     * 根据小区主键获取顺序号
     * @param id 小区id
     * @return
     */
    @GetMapping("getOrderByNum/{id}")
    @ApiOperation(value = "获取顺序号", notes = "获取顺序号")
    public Result getOrderByNum(@PathVariable String id) {
        return fJglService.getOrderByNum(id);
    }
    /**
     * 获取每个小区房间数和方间类型统计
     * @return
     */
    @PostMapping("getbuildingTypeCont")
    @ApiOperation(value = "获取每个小区房间数和方间类型统计", notes = "获取每个小区房间数和方间类型统计")
    public Result getbuildingTypeCont(@RequestBody Map<String,Object> map ) {

        return fJglService.getbuildingTypeCont(map);
    }
    /**
     * 根据楼宇主键查询房间并案楼层展示
     * @return
     */
    @GetMapping("queryVillageByLc/{id}")
    @ApiOperation(value = "根据楼宇主键查询房间并案楼层展示")
    public Result queryVillageByLc(@PathVariable String id) {
        return fJglService.queryVillageByLc(id);
    }
}
